home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreateClip.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  15.2 KB  |  544 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  July 16, 1999
  22. //  Author:         bb
  23. //
  24. //  Description:
  25. //      This script is the create clip option box dialogs.
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. proc setOptionVars (int $forceFactorySettings)
  35. {
  36.     // Clip name
  37.     //
  38.     if ($forceFactorySettings || !`optionVar -exists createClipName`) {
  39.         optionVar -stringValue createClipName "clip1";
  40.     }    
  41.  
  42.     if ($forceFactorySettings || !`optionVar -exists createClipSchedule`) {
  43.         optionVar -intValue createClipSchedule 1;
  44.     }    
  45.  
  46.     if ($forceFactorySettings || !`optionVar -exists createClipSubChar`) {
  47.         optionVar -intValue createClipSubChar 1;
  48.     }    
  49.  
  50.     if( $forceFactorySettings || !`optionVar -exists createClipStart` ) {
  51.         optionVar -floatValue createClipStart 0;
  52.     } 
  53.     
  54.     if( $forceFactorySettings || !`optionVar -exists createClipEnd` ) {
  55.         optionVar -floatValue createClipEnd 10;
  56.     } 
  57.     
  58.     //    createClipTimeWarp
  59.     //     0: No Warp Curve Created
  60.     //    1: Time Warp Curve Created
  61.     //
  62.     if ( $forceFactorySettings || !`optionVar -exists createClipTimeWarp`) {
  63.         optionVar -intValue createClipTimeWarp 0;
  64.     }
  65.  
  66.     //    createClipRangeMethodWhich:
  67.     //    1: set the clip for the selected range
  68.     //    2: set the clip for the time slider range
  69.     //    3: set the clip for the length of the anim curves
  70.     //    4: set the clip for the specified start and end times (default)
  71.     //
  72.     if ( $forceFactorySettings || !`optionVar -exists createClipRangeMethodWhich`) {
  73.         optionVar -intValue createClipRangeMethodWhich 3;
  74.     }
  75.  
  76.     if ($forceFactorySettings || !`optionVar -exists clipHierarchy`) {
  77.         // use hierarchy: default is true
  78.         optionVar -intValue clipHierarchy 1;
  79.     }
  80. }
  81.  
  82. //
  83. //  Procedure Name:
  84. //      createClipSetup
  85. //
  86. //  Description:
  87. //        Update the state of the option box UI to reflect the option values.
  88. //
  89. //  Input Arguments:
  90. //      parent               - Top level parent layout of the option box UI.
  91. //                             Required so that UI object names can be 
  92. //                             successfully resolved.
  93. //
  94. //    forceFactorySettings     - Whether the option values should be set to
  95. //                             default values.
  96. //
  97. //  Return Value:
  98. //      None.
  99. //
  100. global proc createClipSetup (string $parent, int $forceFactorySettings)
  101. {
  102.     // Retrieve the option settings.
  103.     setOptionVars( $forceFactorySettings );
  104.  
  105.     setParent $parent;
  106.     
  107.     // Set the clip name.
  108.     string $name = `optionVar -query createClipName`;
  109.     textFieldGrp -e -text $name clipNameWidget;
  110.  
  111.     // Set the schedule flag
  112.     int $scheduleIt = `optionVar -query createClipSchedule`;
  113.  
  114.     // Set the subcharacter flag
  115.     int $useSubcharacters = `optionVar -query createClipSubChar`;
  116.     checkBoxGrp -edit -value1 $useSubcharacters useSubCharWidget;
  117.  
  118.     switch ($scheduleIt) {
  119.     case 1:
  120.             radioButtonGrp -e -sl 1 scheduleMethod;
  121.             break;
  122.     default:
  123.     case 2:
  124.     case 3:            
  125.             radioButtonGrp -e -sl 1 moveToLibraryMethod;
  126.             break;
  127.     }
  128.     
  129.     // 1 == Remove character's existing animation & add clip to track editor
  130.     // 2 == Remove character's existing animation and add clip to library
  131.     // 3 == Keep existing animation and add clip to library
  132.     //
  133.     if ($scheduleIt == 3) {
  134.         checkBoxGrp -edit -value1 true leaveKeysWidget;
  135.         radioButtonGrp -e -enable false scheduleMethod;
  136.     } else {
  137.         radioButtonGrp -e -enable true scheduleMethod;        
  138.         checkBoxGrp -edit -value1 false leaveKeysWidget;        
  139.     }
  140.  
  141.     //    Set the start and end times.
  142.     float $start = `optionVar -query createClipStart`;
  143.     float $end   = `optionVar -query createClipEnd`;
  144.     floatFieldGrp -edit -value1 $start -enable false frameStartValue;
  145.     floatFieldGrp -edit -value1 $end -enable false frameEndValue;    
  146.  
  147.     // Set the correct radio button.
  148.     int $whichMethod = `optionVar -query createClipRangeMethodWhich`;
  149.     switch($whichMethod) {
  150.         case 1:
  151.             radioButtonGrp -e -sl 1 selectedMethod;
  152.             break;
  153.         case 2:
  154.             radioButtonGrp -e -sl 1 timeSliderMethod;
  155.             break;
  156.         case 3:
  157.             radioButtonGrp -e -sl 1 animCurveMethod;
  158.             break;
  159.         case 4:
  160.         default:
  161.             radioButtonGrp -e -sl 1 startEndMethod;
  162.             floatFieldGrp -e -enable true frameStartValue;
  163.             floatFieldGrp -e -enable true frameEndValue;
  164.             break;
  165.     }
  166.  
  167.     // Set the correct warp curve radio button.
  168.     //
  169.     int $whichWarp = `optionVar -query createClipTimeWarp`;
  170.     checkBoxGrp -edit -value1 $whichWarp createTimeWarpGrp;
  171.  
  172.     checkBoxGrp -edit -value1 `optionVar -query clipHierarchy` clipHierWidget;
  173. }
  174.  
  175. //
  176. //  Procedure Name:
  177. //      createClipCallback
  178. //
  179. //  Description:
  180. //        Update the option values with the current state of the option box UI.
  181. //
  182. //  Input Arguments:
  183. //      parent - Top level parent layout of the option box UI.  Required so
  184. //               that UI object names can be successfully resolved.
  185. //
  186. //    doIt       - Whether the command should execute.
  187. //
  188. //  Return Value:
  189. //      None.
  190. //
  191. global proc createClipCallback (string $parent, int $doIt)
  192. {
  193.     setParent $parent;
  194.  
  195.     // Name
  196.     //
  197.     optionVar -stringValue createClipName
  198.         `textFieldGrp -q -text clipNameWidget`;
  199.  
  200.     // Set the schedule flag
  201.     int $leaveKeys = `checkBoxGrp -query -value1 leaveKeysWidget`;    
  202.  
  203.     int $useSubChar = `checkBoxGrp -query -value1 useSubCharWidget`;    
  204.     optionVar -intValue createClipSubChar $useSubChar;
  205.  
  206.     // if the user selects leaveKeys, dim the scheduleMethod widget, since
  207.     // we only allow you add add the clip to the library if you leave the
  208.     // keys
  209.     //
  210.     if ($leaveKeys) {
  211.         optionVar -intValue createClipSchedule 3;
  212.         radioButtonGrp -e -enable false scheduleMethod;
  213.         radioButtonGrp -e -sl 1 moveToLibraryMethod;        
  214.     } else {
  215.         radioButtonGrp -e -enable true scheduleMethod;        
  216.         if (`radioButtonGrp -q -sl scheduleMethod` == 1) {
  217.             optionVar -intValue createClipSchedule 1;
  218.         } else if (`radioButtonGrp -q -sl moveToLibraryMethod` == 1) {
  219.             optionVar -intValue createClipSchedule 2;
  220.         }
  221.     }
  222.     
  223.     if (`radioButtonGrp -q -sl selectedMethod` == 1) {
  224.         optionVar -intValue createClipRangeMethodWhich 1;
  225.     } else if (`radioButtonGrp -q -sl timeSliderMethod` == 1) {
  226.         optionVar -intValue createClipRangeMethodWhich 2;
  227.     } else if (`radioButtonGrp -q -sl animCurveMethod` == 1) {
  228.         optionVar -intValue createClipRangeMethodWhich 3;
  229.     } else {
  230.         optionVar -intValue createClipRangeMethodWhich 4;
  231.     }
  232.  
  233.     optionVar -floatValue  createClipStart `floatFieldGrp -query -value1 frameStartValue`;
  234.     optionVar -floatValue  createClipEnd `floatFieldGrp -query -value1 frameEndValue`;
  235.  
  236.     int $warpOption = `checkBoxGrp -q -value1 createTimeWarpGrp`;
  237.     optionVar -intValue createClipTimeWarp $warpOption;
  238.  
  239.     optionVar -intValue clipHierarchy `checkBoxGrp -q -value1 clipHierWidget`;
  240.  
  241.     if ($doIt)
  242.         performCreateClip false;
  243. }
  244.  
  245.  
  246. proc string createClipWidgets( string $parent )
  247. {
  248.     setParent $parent;
  249.     
  250.     string $tabForm = `columnLayout -adj true`;
  251.  
  252.     textFieldGrp -label "Name" -text "clip1" -parent $tabForm
  253.             clipNameWidget;
  254.  
  255.     // schedule it
  256.     checkBoxGrp
  257.         -label "Keys"
  258.         -label1 "Leave Keys in Timeline"
  259.         -annotation "Leave Keys In Timeline: Creates a clip and puts it into Visor. It leaves the keys on the timeline so that you can create another clip using the same keys."
  260.         -onc "radioButtonGrp -e -enable false scheduleMethod; radioButtonGrp -e -sl 1 moveToLibraryMethod;"
  261.         -ofc "radioButtonGrp -e -enable true scheduleMethod;"
  262.         -numberOfCheckBoxes 1
  263.         leaveKeysWidget;
  264.     
  265.     // how to schedule it
  266.     radioButtonGrp -numberOfRadioButtons 1
  267.         -label "Clip"
  268.         -label1 "Put Clip in Visor Only"
  269.         -annotation "Put Clip in Visor Only: The clip is put in the Visor for later use."
  270.         moveToLibraryMethod;
  271.  
  272.     radioButtonGrp -numberOfRadioButtons 1
  273.         -label1 "Put Clip in Trax Editor and Visor"
  274.         -annotation "Put Clip in Trax Editor and Visor: The clip is placed in the Trax editor for immediate use. The clip is also put in the Visor for later use."        
  275.         -shareCollection moveToLibraryMethod
  276.         scheduleMethod;
  277.  
  278.     // clip start & duration
  279.     radioButtonGrp -numberOfRadioButtons 1
  280.         -label "Time Range"
  281.         -label1 "Selected"
  282.         -annotation "Selected: The clip start and end are defined by the time range selected on the time slider."
  283.         selectedMethod;
  284.  
  285.     radioButtonGrp -numberOfRadioButtons 1
  286.         -label1 "Time Slider"
  287.         -annotation "Time Slider: The clip start and end are defined by the entire range of the time slider."
  288.         -shareCollection selectedMethod
  289.         timeSliderMethod;
  290.  
  291.     radioButtonGrp -numberOfRadioButtons 1
  292.         -label1 "Animation Curve"
  293.         -annotation "Animation Curve: The clip start and end are defined by the start and end keys of the animation curve(s) in the clip."
  294.         -shareCollection selectedMethod
  295.         animCurveMethod;
  296.  
  297.     radioButtonGrp -numberOfRadioButtons 1
  298.         -label1 "Start/End"
  299.         -annotation "Start/End: Manually enter the clip start and end in the boxes below."
  300.         -select 1
  301.         -shareCollection selectedMethod
  302.         -onCommand "floatFieldGrp -e -enable true frameStartValue; floatFieldGrp -e -enable true frameEndValue;"
  303.         -offCommand "floatFieldGrp -e -enable false frameStartValue; floatFieldGrp -e -enable false frameEndValue;"
  304.         startEndMethod;
  305.  
  306.     frameLayout -bv no -lv no -collapsable no startEndFrame;
  307.         columnLayout -adjustableColumn true;
  308.         floatFieldGrp -label "Start Time" -value1 0.0 frameStartValue;
  309.         floatFieldGrp -label "End Time" -value1 10.0 frameEndValue;
  310.         setParent ..;
  311.         setParent ..;
  312.     setParent ..;
  313.     
  314.     // whether to include subcharacters in the clip
  315.     checkBoxGrp
  316.         -label "Subcharacters"
  317.         -label1 "Include Subcharacters in Clip"
  318.         -annotation "Subcharacters: Whether to create clips for the subcharacters of this character."
  319.         -numberOfCheckBoxes 1
  320.         useSubCharWidget;
  321.  
  322.     // clip time warps
  323.     checkBoxGrp
  324.         -label "Time Warp"
  325.         -label1 "Create Time Warp Curve"
  326.         -annotation "Time Warp: A time warp will be created for later use."
  327.         -numberOfCheckBoxes 1
  328.         createTimeWarpGrp;
  329.  
  330.     separator;
  331.  
  332.     checkBoxGrp
  333.         -label "Include"
  334.         -label1 "Hierarchy"
  335.         -annotation "Hierarchy: When creating the clip, all objects parented beneach the selected objects will be included."
  336.         -numberOfCheckBoxes 1
  337.         clipHierWidget;
  338.  
  339.     return $tabForm;
  340. }
  341.  
  342. global proc createClipOptions ()
  343. {
  344.     string $commandName = "createClip";
  345.  
  346.     string $applyTitle = "Create";
  347.     
  348.     // Build the option box "methods"
  349.     //
  350.     string $callback = ($commandName + "Callback");
  351.     string $setup = ($commandName + "Setup");
  352.  
  353.     //    Get the option box.
  354.     //
  355.     //  The value returned is the name of the layout to be used as
  356.     //    the parent for the option box UI.
  357.     //
  358.     string $layout = getOptionBox();
  359.     setParent $layout;
  360.  
  361.     setOptionBoxCommandName("clip");
  362.  
  363.     setUITemplate -pushTemplate DefaultTemplate;
  364.     waitCursor -state 1;
  365.     tabLayout -scr true -tv false;    // To get the scroll bars
  366.  
  367.     string $parent = `columnLayout -adjustableColumn 1`;
  368.  
  369.     createClipWidgets $parent;
  370.  
  371.     waitCursor -state 0;
  372.     setUITemplate -popTemplate;
  373.  
  374.     //    'Apply' button.
  375.     //
  376.     string $applyBtn = getOptionBoxApplyBtn();
  377.     button -edit
  378.         -label "Create Clip"
  379.         -command ($callback + " " + $parent + " " + 1)
  380.         $applyBtn;
  381.  
  382.     //    'Save' button.
  383.     //
  384.     string $saveBtn = getOptionBoxSaveBtn();
  385.     button -edit 
  386.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  387.         $saveBtn;
  388.  
  389.     //    'Reset' button.
  390.     //
  391.     string $resetBtn = getOptionBoxResetBtn();
  392.     button -edit 
  393.         -command ($setup + " " + $parent + " " + 1)
  394.         $resetBtn;
  395.  
  396.     //    Set the option box title.
  397.     //
  398.     setOptionBoxTitle("Create Clip Options");
  399.  
  400.     //    Customize the 'Help' menu item text.
  401.     //
  402.     setOptionBoxHelpTag( "CreateClip" );
  403.  
  404.     //    Set the current values of the option box.
  405.     //
  406.     eval (($setup + " " + $parent + " " + 0));    
  407.     
  408.     //    Show the option box.
  409.     //
  410.     showOptionBox();
  411. }
  412.  
  413.  
  414. //
  415. //  Procedure Name:
  416. //      assembleCmd
  417. //
  418. //  Description:
  419. //        Construct the command that will apply the option box values.
  420. //
  421. //  Input Arguments:
  422. //      None.
  423. //
  424. //  Return Value:
  425. //      None.
  426. //
  427. proc string assembleCmd()
  428. {
  429.     string $cmd;
  430.  
  431.     setOptionVars(false);
  432.  
  433.     // get the partition name
  434.     string $clipName = "clip1";
  435.     if (`optionVar -exists createClipName`) {
  436.         $clipName = `optionVar -query createClipName`;
  437.     }
  438.  
  439.     int $scheduleIt = 1;
  440.     if (`optionVar -exists createClipSchedule`) {
  441.         $scheduleIt = `optionVar -query createClipSchedule`;
  442.     }
  443.  
  444.     int $useSubChar = 1;
  445.     if (`optionVar -exists createClipSubChar`) {
  446.         $useSubChar = `optionVar -query createClipSubChar`;
  447.     }
  448.  
  449.     string $createMethod = "startEndMethod";
  450.     int $whichMethod = `optionVar -q createClipRangeMethodWhich`;
  451.     switch ($whichMethod) {
  452.         case 1:
  453.             $createMethod = "selectedMethod";
  454.             break;
  455.         case 2:
  456.             $createMethod = "timeSliderMethod";
  457.             break;
  458.         case 3:
  459.             $createMethod = "animCurveMethod";
  460.             break;
  461.     }
  462.  
  463.     string $warpMethod = "noWarp";
  464.     int $timeWarp = `optionVar -q createClipTimeWarp`;
  465.     if ($timeWarp > 0) {
  466.         $warpMethod = "enabledWarp";
  467.     }
  468.  
  469.     int $useHierarchy = 0;
  470.     if (`optionVar -exists clipHierarchy`) {
  471.         $useHierarchy = `optionVar -query clipHierarchy`;
  472.     }
  473.  
  474.     // doCreateClipArgList takes a string array 
  475.     //
  476.     $cmd =    "doCreateClipArgList 4 { " +
  477.                 "\"" + $clipName + "\"" +
  478.                 ",\"" + $scheduleIt + "\"" +        
  479.                 ",\"" + $createMethod + "\"" +
  480.                 ",\"" + `optionVar -query createClipStart` + "\"" +
  481.                 ",\"" + `optionVar -query createClipEnd` + "\"" +
  482.                 ",\"" + $useSubChar + "\"" +
  483.                 ",\"" + $warpMethod + "\"" +
  484.                 ",\"" + $useHierarchy + "\"" +        
  485.             " };";
  486.  
  487.     return $cmd;
  488. }
  489.  
  490. //
  491. //  Procedure Name:
  492. //      performCreateClip
  493. //
  494. //  Description:
  495. //        Create a clip and add the animatable attributes from the 
  496. //      selected nodes.  This procedure will also show the option box
  497. //        window if necessary as well as construct the command string
  498. //        that will create a clip with the current option box values.
  499. //
  500. //  Input Arguments:
  501. //      0 - Execute the command.
  502. //      1 - Show the option box dialog.
  503. //      2 - Return the command.
  504. //
  505. //  Return Value:
  506. //      None.
  507. //
  508. global proc string performCreateClip (int $action)
  509. {
  510.     string $cmd = "";
  511.  
  512.     switch ($action) {
  513.  
  514.         //    Execute the command.
  515.         //
  516.         case 0:
  517.             //    Retrieve the option settings
  518.             //
  519.             setOptionVars(false);
  520.  
  521.             //    Get the command.
  522.             //
  523.             $cmd = `assembleCmd`;
  524.  
  525.             //    Execute the command with the option settings.
  526.             //
  527.             if ($cmd != "")
  528.                 eval($cmd);
  529.             break;
  530.  
  531.         //    Show the option box.
  532.         //
  533.         case 1:
  534.             createClipOptions;
  535.             break;
  536.         case 2:
  537.             //    Get the command.
  538.             //
  539.             $cmd = `assembleCmd`;
  540.     }
  541.     return $cmd;
  542. }
  543.  
  544.